Skip to content

Reduce buffer allocation overhead and add AES-256-CTR binding#110

Merged
zhuizhuhaomeng merged 1 commit intoopenresty:masterfrom
Appla:support-str-buffer
Apr 22, 2026
Merged

Reduce buffer allocation overhead and add AES-256-CTR binding#110
zhuizhuhaomeng merged 1 commit intoopenresty:masterfrom
Appla:support-str-buffer

Conversation

@Appla
Copy link
Copy Markdown
Contributor

@Appla Appla commented Apr 17, 2026

This PR reduces buffer allocation overhead during encrypt/decrypt calls and adds the missing AES-256-CTR OpenSSL binding.

Benchmarks

Benchmark 1: resty  /path/to/test_aes.lua original
  Time (mean ± σ):     718.8 ms ±  51.2 ms    [User: 756.2 ms, System: 11.7 ms]
  Range (min … max):   669.4 ms … 832.0 ms    10 runs

Benchmark 2: resty /path/to/test_aes.lua new
  Time (mean ± σ):     406.3 ms ±  15.9 ms    [User: 425.3 ms, System: 6.3 ms]
  Range (min … max):   387.0 ms … 438.4 ms    10 runs

Summary
 resty /path/to/test_aes.lua new ran
    1.77 ± 0.14 times faster than /path/to/test_aes.lua original

Changes

  • add the missing EVP_aes_256_ctr declaration
  • reuse output and tag scratch buffers in encrypt/decrypt
  • use string.buffer when available, with FFI fallback

@zhuizhuhaomeng zhuizhuhaomeng merged commit 595f066 into openresty:master Apr 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants